
<template>
  <view class="build-notification-page">
    <!-- 分类Tab切换 -->
    <view class="category-tab-container">
      <view
          class="category-tab-item"
          :class="{ active: activeCategory === 'payment' }"
          @tap="switchCategory('payment')"
      >
        付款通知
      </view>
      <view
          class="category-tab-item"
          :class="{ active: activeCategory === 'change' }"
          @tap="switchCategory('change')"
      >
        变更通知
      </view>
    </view>

    <!-- 状态Tab切换 -->
    <view class="status-tab-container">
      <view
          class="status-tab-item"
          :class="{ active: activeStatus === 'unread' }"
          @tap="switchStatus('unread')"
      >
        未读
      </view>
      <view
          class="status-tab-item"
          :class="{ active: activeStatus === 'read' }"
          @tap="switchStatus('read')"
      >
        已读
      </view>
    </view>

    <!-- 通知列表 -->
    <scroll-view class="notification-list" scroll-y>
      <view
          class="notification-item"
          :class="{ 'unread-item': isActiveUnread, 'read-item': !isActiveUnread }"
          v-for="(item, index) in currentNotifications"
          :key="index"
          @tap="viewNotificationDetail(item)"
      >
        <view class="notification-content">
          <text class="notification-title">{{ item.title }}</text>
          <view class="notification-meta">
            <text class="notification-date">{{ item.date }}</text>
            <text class="notification-sender">{{ item.sender }}</text>
          </view>
        </view>
        <view class="notification-status" v-if="isActiveUnread">
          <view class="unread-dot"></view>
        </view>
      </view>

      <!-- 空状态 -->
      <view v-if="currentNotifications.length === 0" class="empty-state">
        <text class="empty-text">暂无相关通知</text>
      </view>
    </scroll-view>
  </view>
</template>

<script>export default {
  data() {
    return {
      activeCategory: 'payment', // payment(缴费通知) | change(变更通知)
      activeStatus: 'unread',    // unread(未读) | read(已读)
      notifications: {
        payment: {
          unread: [
            {
              id: 1,
              title: '阶段付款提醒',
              date: '2024-01-15 14:30',
              sender: '财务部',
              content: '尊敬的业主，您的工地已进入水电工程阶段，请于3日内支付该阶段款项共计￥15,000元。'
            },
            {
              id: 2,
              title: '材料费补缴通知',
              date: '2024-01-14 10:15',
              sender: '项目经理',
              content: '因您选择升级瓷砖品牌，需补缴材料差价￥3,500元，请尽快完成支付。'
            }
          ],
          read: [
            {
              id: 3,
              title: '首期款支付确认',
              date: '2024-01-10 09:30',
              sender: '财务部',
              content: '已收到您支付的首期款￥20,000元，感谢您的及时支付。'
            },
            {
              id: 4,
              title: '尾款支付提醒',
              date: '2024-01-05 16:45',
              sender: '财务部',
              content: '您的装修工程已完工，请于本周内支付尾款￥10,000元。'
            }
          ]
        },
        change: {
          unread: [
            {
              id: 5,
              title: '设计变更确认',
              date: '2024-01-15 11:20',
              sender: '设计师',
              content: '根据您的要求，客厅吊顶设计已调整为简约风格，请确认变更方案。'
            },
            {
              id: 6,
              title: '施工方案调整',
              date: '2024-01-14 15:30',
              sender: '项目经理',
              content: '因墙体结构问题，原定厨房位置需向左移动50cm，请知悉。'
            }
          ],
          read: [
            {
              id: 7,
              title: '材料品牌变更',
              date: '2024-01-12 14:15',
              sender: '采购部',
              content: '原定的瓷砖品牌暂时缺货，已更换为同等级别的替代品牌。'
            },
            {
              id: 8,
              title: '工期调整通知',
              date: '2024-01-08 09:45',
              sender: '项目总监',
              content: '因春节假期影响，整体验收时间将延后一周，请知悉。'
            }
          ]
        }
      }
    }
  },
  computed: {
    currentNotifications() {
      return this.notifications[this.activeCategory][this.activeStatus];
    },
    isActiveUnread() {
      return this.activeStatus === 'unread';
    }
  },
  methods: {
    switchCategory(category) {
      this.activeCategory = category;
    },

    switchStatus(status) {
      this.activeStatus = status;
    },

    viewNotificationDetail(notification) {
      // 跳转到通知详情页
      uni.navigateTo({
        url: `/pages/user/build-notifications_detail?id=${notification.id}&category=${this.activeCategory}`
      });
    }
  }
}
</script>

<style lang="scss" scoped>.build-notification-page {
  background-color: #f5f5f5;
  min-height: 100vh;
  padding: 20rpx;
}

.header-section {
  margin-bottom: 30rpx;
}

.page-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
  position: relative;
  padding-left: 20rpx;
}

.page-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8rpx;
  height: 36rpx;
  background: linear-gradient(to bottom, #e4393c, #409EFF);
  border-radius: 4rpx;
}

/* 分类Tab样式 */
.category-tab-container {
  display: flex;
  background-color: #fff;
  border-radius: 16rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.category-tab-item {
  flex: 1;
  text-align: center;
  padding: 24rpx 0;
  font-size: 28rpx;
  color: #666;
  position: relative;
}

.category-tab-item.active {
  color: #e4393c;
  font-weight: bold;
}

.category-tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 6rpx;
  background-color: #e4393c;
  border-radius: 3rpx;
}

/* 状态Tab样式 */
.status-tab-container {
  display: flex;
  background-color: #fff;
  border-radius: 16rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.status-tab-item {
  flex: 1;
  text-align: center;
  padding: 20rpx 0;
  font-size: 26rpx;
  color: #666;
  position: relative;
}

.status-tab-item.active {
  color: #409EFF;
  font-weight: bold;
}

.status-tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30%;
  height: 4rpx;
  background-color: #409EFF;
  border-radius: 2rpx;
}

.notification-list {
  flex: 1;
}

.notification-item {
  background-color: #fff;
  border-radius: 16rpx;
  margin-bottom: 20rpx;
  padding: 30rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
}

.notification-content {
  flex: 1;
}

.notification-title {
  display: block;
  font-size: 26rpx;
  color: #333;
  margin-bottom: 16rpx;
  font-weight: 500;
}

.notification-meta {
  display: flex;
  justify-content: space-between;
}

.notification-date {
  font-size: 24rpx;
  color: #999;
}

.notification-sender {
  font-size: 24rpx;
  color: #666;
}

.notification-status {
  margin-left: 20rpx;
}

.unread-dot {
  width: 16rpx;
  height: 16rpx;
  background-color: #e4393c;
  border-radius: 50%;
}

.read-item {
  opacity: 0.8;
}

.read-item .notification-title {
  color: #666;
}

.empty-state {
  text-align: center;
  padding: 100rpx 0;
}

.empty-text {
  color: #999;
  font-size: 28rpx;
}
</style>